package com.yanqu.road.entity.player;

import com.yanqu.road.entity.DataObject;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class UserBuilding extends DataObject {

	/**
	 * 玩家ID
	 */
	private long userId;
	/**
	 * 建筑ID
	 */
	private int buildingId;
	/**
	 * 建筑等级
	 */
	private int level;
	/**
	 * 招募员工数目
	 */
	private int staffCount;

	/**
	 * 技能加成固定值
	 */
	private int addStaffCount;

	private Long lastUpdateTime;

	private List<Integer> patronsIdList = new ArrayList<>();

	private BigInteger buildingEarnSpeed = BigInteger.ZERO;        //店铺赚速缓存

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		if (this.userId != userId) {
			this.userId = userId;
			setUpdateOption();
		}
	}

	public int getBuildingId() {
		return buildingId;
	}

	public void setBuildingId(int buildingId) {
		if (this.buildingId != buildingId) {
			this.buildingId = buildingId;
			setUpdateOption();
		}

	}

	public int getTotalStaffCount(){
		return staffCount + addStaffCount;
	}

	public int getStaffCount() {
		return staffCount;
	}

	public void setStaffCount(int staffCount) {
		if (this.staffCount != staffCount) {
			this.staffCount = staffCount;
			setUpdateOption();
		}
	}

	public Long getLastUpdateTime() {
		return lastUpdateTime;
	}

	public void setLastUpdateTime(Long lastUpdateTime) {
		if (this.lastUpdateTime != lastUpdateTime) {
			this.lastUpdateTime = lastUpdateTime;
			setUpdateOption();
		}
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		if (this.level != level) {
			this.level = level;
			setUpdateOption();
		}
	}

	public List<Integer> getPatronsIdList() {
		return patronsIdList;
	}

	public void setPatronsIdList(List<Integer> patronsIdList) {
		this.patronsIdList = patronsIdList;
		setUpdateOption();
	}

	public void addPatronsId(int patronsId) {
		if(!patronsIdList.contains(Integer.valueOf(patronsId))) {
			patronsIdList.add(patronsId);
			setUpdateOption();
		}
	}

	public void resetPatrons() {
		patronsIdList = new ArrayList<>();
		setUpdateOption();
	}

	public void removePatrons(int patronsId) {
		patronsIdList.remove(Integer.valueOf(patronsId));
		setUpdateOption();
	}

	public BigInteger getBuildingEarnSpeed() {
		return buildingEarnSpeed;
	}

	public void setBuildingEarnSpeed(BigInteger buildingEarnSpeed) {
		this.buildingEarnSpeed = buildingEarnSpeed;
	}

	public int getAddStaffCount() {
		return addStaffCount;
	}

	public void setAddStaffCount(int addStaffCount) {
		this.addStaffCount = addStaffCount;
	}
}
